Skip to content

fix(http): percent-encode binary mode header values - #803

Open
EmiRZx wants to merge 1 commit into
cloudevents:mainfrom
EmiRZx:http-header-percent-encoding
Open

EmiRZx wants to merge 1 commit into
cloudevents:mainfrom
EmiRZx:http-header-percent-encoding

Conversation

@EmiRZx

@EmiRZx EmiRZx commented Dec 5, 2026 •

Copy link
Copy Markdown

Fixes #748

binary mode wrote attribute values to ce- headers as they were and read them back unchanged. this implements section 3.1.3.2 of the HTTP binding as clarified in cloudevents/spec#1402. it follows cloudevents/sdk-go#1356.

on write the UTF-8 bytes outside U+0021-U+007E are percent-encoded along with % and ". a space is only encoded when it's leading or trailing. on read the value is trimmed. quotes are removed after their backslash escapes are resolved and then %XX is decoded. a % without two hex digits after it is kept. bytes that aren't valid UTF-8 are rejected with INVALID_ATTRIBUTE_VALUE. Content-Type isn't touched in either direction.

the helper is HttpHeaderValues in core since vertx and restful-ws don't depend on http-basic. it's used by the http-basic, vertx and restful-ws readers and writers and by the spring webflux writer. spring's other paths go through http-basic.

this changes the wire format for values with those characters. an unfixed receiver sees 100%25 instead of 100%. a %XX from an unfixed sender is now decoded. so ce-source: https://x/a%20b becomes https://x/a b and is rejected as a URI. sdk-go made the change without a switch so I didn't add one. duglin suggested a flag for a transition period in cloudevents/spec#1397. I can add one if you'd like.

encode and decode give the same results as sdk-go's on 40 inputs. the new binding tests use a subject of 100% "sure" € and fail without the change.

Encode the values of ce- headers on write and decode them on read as
described in section 3.1.3.2 of the HTTP protocol binding.

Signed-off-by: emir <52245396+EmiRZx@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP binary mode does not percent-encode or decode header values (spec 3.1.3.2)

1 participant